<?php

namespace App\Models;

use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;
use Encore\Admin\Traits\DefaultDatetimeFormat;

class Obj extends Model
{
    use DefaultDatetimeFormat, ModelTree;

    protected $table = 'obj';

    public $sortable = [
        'order_column_name' => 'order',
        'sort_when_creating' => true,
    ];

    public static function grid($callback)
    {
        return new Grid(new static, $callback);
    }

    public static function form($callback)
    {
        return new Form(new static, $callback);
    }

    public function nation()
    {
        return $this->belongsTo(Nation::class, 'nation_id', 'id');
    }


    public function city()
    {
        return $this->belongsTo(City::class, 'city_id', 'id');
    }

    public function county()
    {
        return $this->belongsTo(City::class, 'county_id', 'id');
    }
}
